﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using BLL;

public partial class SendVerifyCode : System.Web.UI.Page
{
    ConsultationCardPwdSelect bllCardPwdSelect = new ConsultationCardPwdSelect();
    SendSMS bllPhone = new SendSMS();
    ReadParamtes bllParams = new ReadParamtes();
    string action = string.Empty;
    string id = string.Empty;
    string page = string.Empty;
    string pagehtml = string.Empty;
    string linkhtml = string.Empty;
    
    string mobileNO = string.Empty;

    int Pages = 5;

    string commentparentid = string.Empty;
    string commentuser = string.Empty;
    string commenttext = string.Empty;
    string commentvalidate = string.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {
        action = Request.QueryString["action"];
        id = Request.QueryString["id"];
        page = Request.QueryString["page"];

        commentparentid = Request.QueryString["commentparentid"];
        mobileNO = Request.QueryString["number"];

        if (action == "ajax_getcomment")
        {
            ajax_getcomment(id, Int32.Parse(page));
        }
        else if (action == "ajax_sendcomment")
        {
            bllCardPwdSelect.IsExistsVerifyCode(mobileNO);
            string code = WebUtility.RndStr().ToString();
            string newTempMsg = "";
            DataTable dt = new DataTable();
            dt = bllParams.GetVerifyCodeMsgTemp();

            if (dt.Rows.Count <= 0)
            {
                return;
            }
            else
            {
                string oldTempMsg = dt.Rows[0]["ParameterValue"].ToString();
                newTempMsg = WebUtility.GenrateSendVerifyCodeMsgTemp(code, oldTempMsg);
            }

            bllPhone.SendMsg(newTempMsg, mobileNO, "2");

            Response.Write("验证码已发送到您的手机上，请注意查收！");
        }
        else
        {
            Response.Write("验证码发送失败，请稍后重试!");
        }

    }

    private void ajax_getcomment(string id, int page)
    {

    }
}
